package com.cadre.common.utils.oldutil;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.text.ParseException;
import java.util.*;

/* loaded from: JSONCompareUtil.class */
public class JSONCompareUtil {
    public static StringBuffer before = new StringBuffer();
    public static StringBuffer after = new StringBuffer();
    public static List<Map<String, Object>> columns = new ArrayList();

    public JSONCompareUtil(List<Map<String, Object>> columns2) {
        columns = columns2;
        after = new StringBuffer();
        before = new StringBuffer();
    }

    public static Map<String, Object> compareJson(JSONObject json1, JSONObject json2, String key) {
        for (Object obj : json1.keySet()) {
            String key2 = obj.toString();
            if (json1 == null) {
                json1 = new JSONObject();
            }
            if (json2 == null) {
                json2 = new JSONObject();
            }
            compareJson(json1.get(key2), json2.get(key2), key2);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("before", before);
        map.put("after", after);
        return map;
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:13:0x007c
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    public static void compareJson(Object r5, Object r6, String r7) {
        /*
            r0 = r5
            boolean r0 = r0 instanceof com.alibaba.fastjson.JSONObject
            if (r0 == 0) goto L_0x0017
            r0 = r5
            com.alibaba.fastjson.JSONObject r0 = (com.alibaba.fastjson.JSONObject) r0
            r1 = r6
            com.alibaba.fastjson.JSONObject r1 = (com.alibaba.fastjson.JSONObject) r1
            r2 = r7
            java.util.Map r0 = compareJson(r0, r1, r2)
            goto L_0x00dd
        L_0x0017:
            r0 = r5
            boolean r0 = r0 instanceof com.alibaba.fastjson.JSONArray
            if (r0 == 0) goto L_0x002d
            r0 = r5
            com.alibaba.fastjson.JSONArray r0 = (com.alibaba.fastjson.JSONArray) r0
            r1 = r6
            com.alibaba.fastjson.JSONArray r1 = (com.alibaba.fastjson.JSONArray) r1
            r2 = r7
            compareJson(r0, r1, r2)
            goto L_0x00dd
        L_0x002d:
            r0 = r5
            boolean r0 = r0 instanceof java.lang.String
            if (r0 == 0) goto L_0x00bf
            java.text.SimpleDateFormat r0 = new java.text.SimpleDateFormat
            r1 = r0
            java.lang.String r2 = "yyyy-MM-dd"
            r1.<init>(r2)
            r8 = r0
            java.util.Date r0 = new java.util.Date     // Catch: Exception -> 0x0090
            r1 = r0
            r2 = r5
            java.lang.String r2 = java.lang.String.valueOf(r2)     // Catch: Exception -> 0x0090
            r1.<init>(r2)     // Catch: Exception -> 0x0090
            r9 = r0
            r0 = r8
            r1 = r9
            java.lang.String r0 = r0.format(r1)     // Catch: Exception -> 0x0090
            java.lang.String r0 = r0.toLowerCase()     // Catch: Exception -> 0x0090
            r10 = r0
            java.util.Date r0 = new java.util.Date     // Catch: Exception -> 0x0090, Exception -> 0x007c
            r1 = r0
            r2 = r6
            java.lang.String r2 = java.lang.String.valueOf(r2)     // Catch: Exception -> 0x0090, Exception -> 0x007c
            long r2 = java.lang.Long.parseLong(r2)     // Catch: Exception -> 0x0090, Exception -> 0x007c
            r1.<init>(r2)     // Catch: Exception -> 0x0090, Exception -> 0x007c
            r11 = r0
            r0 = r8
            r1 = r11
            java.lang.String r0 = r0.format(r1)     // Catch: Exception -> 0x0090, Exception -> 0x007c
            java.lang.String r0 = r0.toLowerCase()     // Catch: Exception -> 0x0090, Exception -> 0x007c
            r12 = r0
            r0 = r10
            r1 = r12
            r2 = r7
            compareJson(r0, r1, r2)     // Catch: Exception -> 0x0090, Exception -> 0x007c
            goto L_0x008d
        L_0x007c:
            r11 = move-exception
            r0 = r8
            r1 = r9
            java.lang.String r0 = r0.format(r1)     // Catch: Exception -> 0x0090
            java.lang.String r0 = r0.toLowerCase()     // Catch: Exception -> 0x0090
            java.lang.String r1 = ""
            r2 = r7
            compareJson(r0, r1, r2)     // Catch: Exception -> 0x0090
        L_0x008d:
            goto L_0x00bc
        L_0x0090:
            r9 = move-exception
            r0 = r5
            java.lang.String r0 = java.lang.String.valueOf(r0)
            if (r0 != 0) goto L_0x009e
            java.lang.String r0 = ""
            goto L_0x00a5
        L_0x009e:
            r0 = r5
            java.lang.String r0 = java.lang.String.valueOf(r0)
            java.lang.String r0 = r0.toLowerCase()
        L_0x00a5:
            r1 = r6
            java.lang.String r1 = java.lang.String.valueOf(r1)
            if (r1 != 0) goto L_0x00b1
            java.lang.String r1 = ""
            goto L_0x00b8
        L_0x00b1:
            r1 = r6
            java.lang.String r1 = java.lang.String.valueOf(r1)
            java.lang.String r1 = r1.toLowerCase()
        L_0x00b8:
            r2 = r7
            compareJson(r0, r1, r2)
        L_0x00bc:
            goto L_0x00dd
        L_0x00bf:
            r0 = r5
            if (r0 != 0) goto L_0x00c8
            java.lang.String r0 = ""
            goto L_0x00cc
        L_0x00c8:
            r0 = r5
            java.lang.String r0 = r0.toString()
        L_0x00cc:
            r1 = r6
            if (r1 != 0) goto L_0x00d5
            java.lang.String r1 = ""
            goto L_0x00d9
        L_0x00d5:
            r1 = r6
            java.lang.String r1 = r1.toString()
        L_0x00d9:
            r2 = r7
            compareJson(r0, r1, r2)
        L_0x00dd:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.compareJson(java.lang.Object, java.lang.Object, java.lang.String):void");
    }

    public static void compareJson(String str1, String str2, String key) {
        String str12 = str1.replace("null", "").trim();
        String str22 = str2.replace("null", "").trim();
        if (!str12.equals(str22)) {
            setBefore(key, str22);
            setAfter(key, str12);
            System.out.println("key:" + key + ",json1:" + str12 + ",json2:" + str22);
        }
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:10:0x0072
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    private static void setAfter(String r5, String r6) {
        /*
            java.util.List<java.util.Map<java.lang.String, java.lang.Object>> r0 = com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.columns     // Catch: Exception -> 0x007d
            java.util.Iterator r0 = r0.iterator()     // Catch: Exception -> 0x007d
            r7 = r0
        L_0x0009:
            r0 = r7
            boolean r0 = r0.hasNext()     // Catch: Exception -> 0x007d
            if (r0 == 0) goto L_0x007a
            r0 = r7
            java.lang.Object r0 = r0.next()     // Catch: Exception -> 0x007d
            java.util.Map r0 = (java.util.Map) r0     // Catch: Exception -> 0x007d
            r8 = r0
            r0 = r8
            java.lang.String r1 = "COLUMN_NAME"
            java.lang.Object r0 = r0.get(r1)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r0 = r0.toString()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r0 = r0.toLowerCase()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r1 = r5
            boolean r0 = r0.equals(r1)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            if (r0 == 0) goto L_0x006f
            java.lang.StringBuffer r0 = com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.after     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.StringBuilder r1 = new java.lang.StringBuilder     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r2 = r1
            r2.<init>()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r2 = r8
            java.lang.String r3 = "COMMENTS"
            java.lang.Object r2 = r2.get(r3)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r2 = r2.toString()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r3 = "锛�"
            java.lang.String[] r2 = r2.split(r3)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r3 = 0
            r2 = r2[r3]     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r3 = ","
            java.lang.String[] r2 = r2.split(r3)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r3 = 0
            r2 = r2[r3]     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r2 = ":\r\n"
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r2 = r6
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r2 = "\r\n"
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r1 = r1.toString()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.StringBuffer r0 = r0.append(r1)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            goto L_0x007a
        L_0x006f:
            goto L_0x0077
        L_0x0072:
            r9 = move-exception
            goto L_0x0009
        L_0x0077:
            goto L_0x0009
        L_0x007a:
            goto L_0x007e
        L_0x007d:
            r7 = move-exception
        L_0x007e:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.setAfter(java.lang.String, java.lang.String):void");
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: Unreachable block: B:10:0x0072
        	at jadx.core.dex.visitors.blocks.BlockProcessor.checkForUnreachableBlocks(BlockProcessor.java:86)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:52)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    private static void setBefore(String r5, String r6) {
        /*
            java.util.List<java.util.Map<java.lang.String, java.lang.Object>> r0 = com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.columns     // Catch: Exception -> 0x007d
            java.util.Iterator r0 = r0.iterator()     // Catch: Exception -> 0x007d
            r7 = r0
        L_0x0009:
            r0 = r7
            boolean r0 = r0.hasNext()     // Catch: Exception -> 0x007d
            if (r0 == 0) goto L_0x007a
            r0 = r7
            java.lang.Object r0 = r0.next()     // Catch: Exception -> 0x007d
            java.util.Map r0 = (java.util.Map) r0     // Catch: Exception -> 0x007d
            r8 = r0
            r0 = r8
            java.lang.String r1 = "COLUMN_NAME"
            java.lang.Object r0 = r0.get(r1)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r0 = r0.toString()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r0 = r0.toLowerCase()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r1 = r5
            boolean r0 = r0.equals(r1)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            if (r0 == 0) goto L_0x006f
            java.lang.StringBuffer r0 = com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.before     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.StringBuilder r1 = new java.lang.StringBuilder     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r2 = r1
            r2.<init>()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r2 = r8
            java.lang.String r3 = "COMMENTS"
            java.lang.Object r2 = r2.get(r3)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r2 = r2.toString()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r3 = "锛�"
            java.lang.String[] r2 = r2.split(r3)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r3 = 0
            r2 = r2[r3]     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r3 = ","
            java.lang.String[] r2 = r2.split(r3)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r3 = 0
            r2 = r2[r3]     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r2 = ":\r\n"
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            r2 = r6
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r2 = "\r\n"
            java.lang.StringBuilder r1 = r1.append(r2)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.String r1 = r1.toString()     // Catch: Exception -> 0x007d, Exception -> 0x0072
            java.lang.StringBuffer r0 = r0.append(r1)     // Catch: Exception -> 0x007d, Exception -> 0x0072
            goto L_0x007a
        L_0x006f:
            goto L_0x0077
        L_0x0072:
            r9 = move-exception
            goto L_0x0009
        L_0x0077:
            goto L_0x0009
        L_0x007a:
            goto L_0x007e
        L_0x007d:
            r7 = move-exception
        L_0x007e:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tdqy.cadre.modular.profess.utils.JSONCompareUtil.setBefore(java.lang.String, java.lang.String):void");
    }

    public static void compareJson(JSONArray json1, JSONArray json2, String key) {
        try {
            Iterator i1 = json1.iterator();
            Iterator i2 = json2.iterator();
            while (i1.hasNext()) {
                compareJson(i1.next(), i2.next(), key);
            }
        } catch (Exception e) {
        }
    }

    public static JSONObject getJson(String url) {
        try {
            InputStream in = new URL(url).openStream();
            OutputStream out = new ByteArrayOutputStream();
            IOUtils.copy(in, out);
            String aa = out.toString();
            in.close();
            out.close();
            return JSONObject.parseObject(aa);
        } catch (Exception e) {
            e.printStackTrace();
            return new JSONObject();
        }
    }

    public static void main(String[] args) throws ParseException {
    }

    public StringBuffer getBefore() {
        return before;
    }

    public void setBefore(StringBuffer before2) {
        before = before2;
    }

    public StringBuffer getAfter() {
        return after;
    }

    public void setAfter(StringBuffer after2) {
        after = after2;
    }
}
